	<!-- BEGIN header -->
	<include file="public:header" />
	<!-- END header -->

	<!-- BEGIN CONTAINER -->

	<div class="page-container row-fluid">
		{$left_menu}
		<!-- BEGIN PAGE -->

		<div class="page-content">

			

			<!-- BEGIN PAGE CONTAINER-->        

			<div class="container-fluid">

				<!-- BEGIN PAGE HEADER-->

				<div class="row-fluid">

					<div class="span12">

						<!-- BEGIN STYLE CUSTOMIZER -->

						<!-- END BEGIN STYLE CUSTOMIZER -->  

						<!-- BEGIN PAGE TITLE & BREADCRUMB-->
						<include file="public:breadcrumb" />
						<!-- END PAGE TITLE & BREADCRUMB-->
						
						<!-- BEGIN sub_menu -->
						<include file="public:sub_menu" />
						<!-- END sub_menu -->

					</div>

				</div>

				<!-- END PAGE HEADER-->

				<!-- BEGIN PAGE CONTENT-->
				<div class="row-fluid">

					<div class="span12">

						<!-- BEGIN VALIDATION STATES-->

						<div class="portlet box blue">

							<div class="portlet-title">

								<div class="caption"><i class="icon-reorder"></i>题目信息</div>

								<div class="tools">

									<a href="javascript:;" class="collapse"></a>

								</div>

							</div>

							<div class="portlet-body form">

								<!-- BEGIN FORM-->

								<form action="" method="post" id="form_sample_1" class="form-horizontal" novalidate="novalidate">

									<div class="control-group">

										<label class="control-label">题目</label>

										<div class="controls">

											<input name="title" class="span6 m-wrap" type="text" value="{$info.title}">

										</div>

									</div>
									<php>
									$content = json_decode($info['content'],1);
									$count = count($content);
									</php>
									<div class="control-group">

										<label class="control-label">选项 1</label>

										<div class="controls">

											<input name="content[1]" class="span6 m-wrap" type="text" data_name="content_1" value="{$content[1]}">
											
											<a href="#" type="button" class="btn blue" id="add_content">+</a>

										</div>

									</div>
									
									<if condition="($count gt 1)">
									<volist name="content" id="v" key="k" >
									<if condition="($k neq 1)">
									<div class="control-group">

										<label class="control-label">选项 {$k}<span class="required">*</span></label>

										<div class="controls">

											<input name="content[{$k}]" class="span6 m-wrap" type="text"  data-required="1" data_name="content_{$k}" value="{$v}">
											
											<a href="#" type="button" class="btn blue" data_id="{$k}" onclick="del_content(this)">-</a>

										</div>

									</div>
									</if>
									</volist>
									</if>
									
									
									<div class="control-group">

										<label class="control-label">答案</label>

										<div class="controls">

											<select class="span6 m-wrap" name="answer">
									<if condition="($count eq 0)">
									<option value="1" >选项 1</option>
									</if>
									<if condition="($count egt 1)">
									<volist name="content" id="v" key="k" >
												<option value="{$k}" <if condition="$info.answer eq $k">selected</if>>选项 {$k}</option>
									</volist>
									</if>
											</select>

										</div>

									</div>
									
									<div class="control-group">

										<label class="control-label">排序</label>

										<div class="controls">

											<input name="ordid" class="span6 m-wrap" type="text" value="{$info.ordid}">

										</div>

									</div>

									<div class="control-group">

										<label class="control-label">是否启用</label>
										
										<div class="controls">

											<label class="radio">

											<input name="status" value="1" type="radio" <if condition="($info.status eq 1) OR (ACTION_NAME eq 'add')"> checked="checked"</if>>

											启用

											</label>

											<label class="radio">

											<input name="status" value="0" type="radio" <if condition="($info.status eq 0) and (ACTION_NAME eq 'edit')"> checked="checked"</if>>

											不启用

											</label>

										</div>

									</div>
									
									<input type="hidden" name="id" value="{$info.id}" />
									<input type="hidden" name="class_list_id" value="<if condition="(ACTION_NAME eq 'add')">{$_GET['class_list_id']}</if><if condition="(ACTION_NAME eq 'edit')">{$info.class_list_id}</if>" />

									<div class="form-actions">

										<button type="submit" class="btn blue">
											<if condition="(ACTION_NAME eq 'add')">添加</if>
											<if condition="(ACTION_NAME eq 'edit')">编辑</if>
										</button>

										<a href="javascript:history.go(-1)" type="button" class="btn">取消</a>

									</div>

								</form>

								<!-- END FORM-->

							</div>

						</div>

						<!-- END VALIDATION STATES-->

					</div>

				</div>
				

				

				<!-- END PAGE CONTENT-->

			</div>

			<!-- END PAGE CONTAINER-->

		</div>

		<!-- END PAGE -->

	</div>

	<!-- END CONTAINER -->
	
	<!-- BEGIN FOOTER -->
	<include file="public:footer" />
	<!-- END FOOTER -->
	<script>
	var content_num = ({$count} > 1)?{$count}:1;
	$(function(){
		$("#add_content").click(function(){
		
			add_content();
		});
		//
		
	});
	
	function add_content(){
		var num = content_num;
		content_num++;
		var txt="<div class='control-group'><label class='control-label'>选项 "+content_num+"<span class='required'>*</span></label><div class='controls'><input name='content["+content_num+"]' class='span6 m-wrap' type='text'  data-required='1' data_name='content_"+content_num+"'><a href='#' type='button' class='btn blue' data_id='"+content_num+"' onclick='del_content(this)'>-</a></div></div>";
		$("input[data_name='content_"+num+"']").parent().parent().after(txt);
		var op = "<option value='"+content_num+"' >选项 "+content_num+"</option>";
		$("select[name='answer']").append(op);
	}
	function del_content(obj){
		var num = $(obj).attr('data_id');
		$(obj).parent().parent().remove();
		$("select[name='answer'] option[value='"+num+"']").remove();
		sort_content(num);
		content_num--;
	}
	function sort_content(num){
		//当删除中间的选项之后 就进入排序
		if(num<content_num){
			var k= parseInt(num) + 1;
			$("select[name='answer'] option[value='"+k+"']").html('选项 '+num).val(num);
			$("input[data_name='content_"+k+"']").parent().prev().html('选项 '+num+'');
			$("input[data_name='content_"+k+"']").next().attr('data_id',num);
			$("input[data_name='content_"+k+"']").attr({'name':'content['+num+']','data_name':'content_'+num});
			sort_content(k);
		}
	}
    </script>
</html>